<?php
/**
 * Created by PhpStorm.
 * User: nightelf
 * Date: 2020/2/13
 * Time: 16:06
 */

namespace App\Http\Model;


use Illuminate\Support\Facades\DB;

class ApprovalNodeModel
{
    const TABLE = 'approval_node';

    /**
     * @return mixed
     */
    public function lists()
    {
        return DB::table(self::TABLE)
            ->orderBy('process')
            ->get()->toArray();
    }

    public function countLists()
    {
        return DB::table(self::TABLE)->count();
    }

    /**
     * @param array $data
     * @return mixed
     */
    public function delete(array $data)
    {
        return DB::table(self::TABLE)->where($data)->delete();
    }

    public function insert(array $data)
    {
        return DB::table(self::TABLE)->insert($data);
    }

    public function info(array $where)
    {
        $result = DB::table(self::TABLE)->where($where)->first();
        return empty($result)?[]:get_object_vars($result);
    }
}